/**
 * Project: ld.biz.service
 * 
 * File Created at 2012-9-23
 * $Id$
 * 
 * Copyright 1999-2100 Alibaba.com Corporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Alibaba Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Alibaba.com.
 */
package com.liangdev.biz.core.autocode;

import java.io.File;

import com.liangdev.biz.dataobject.autocode.TemplateInfoDO;
import com.liangdev.biz.service.autocode.TemplateInfoService;

/**
 * TODO Comment of TemplateFileManager
 * 
 * @author chongan.wangca
 */
public class TemplateFileManager {

    private String              templateFilesLocate;

    private TemplateInfoService templateInfoService;

    public File getTemplateFile(Long templateInfoId) {
        TemplateInfoDO templateInfoDO = templateInfoService.findById(templateInfoId);
        if (templateInfoDO == null) {
            return null;
        }
        File file = new File(this.templateFilesLocate + templateInfoDO.getFileName());
        return file.exists() ? file : null;
    }

    public void setTemplateInfoService(TemplateInfoService templateInfoService) {
        this.templateInfoService = templateInfoService;
    }

    /**
     * @param templateFilesLocate the templateFilesLocate to set
     */
    public void setTemplateFilesLocate(String templateFilesLocate) {
        this.templateFilesLocate = templateFilesLocate;
    }

}
